package com.charmzenus.it.common.dto.response;

import com.charmzenus.it.common.constants.CodeNumber;

public class BaseResponseDTO<T> {

    private int code = CodeNumber.success_code;
    private T data = null;
    private String msg = "success";

    public BaseResponseDTO() {
    }

    public BaseResponseDTO(String msg) {
        this.msg = msg;
    }

    public BaseResponseDTO(int code) {
        this.code = code;
    }

    public BaseResponseDTO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BaseResponseDTO(T data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    @Override
    public String toString() {
        if (data == null){
            return "BaseResponseDTO{" +
                    "code=" + code +
                    ", data=" + data +
                    ", msg='" + msg + '\'' +
                    '}';
        } else{
            return "BaseResponseDTO{" +
                    "code=" + code +
                    ", data=" + data.toString() +
                    ", msg='" + msg + '\'' +
                    '}';
        }

    }
}
